/*
 * Copyright (C) 2008-2009 Google Inc. 
 * Copyright (C) 2013 Winson Wong
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Source is base on Android API Source 16  
 */
package myidea.winson.android.cangjieime;

import myidea.winson.android.cangjieime.Keyboard.Row;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;

/**
 * Class for describing Cangjie key
 * @author winson
 *
 * @attr ref R.styleable#Cangjie_Keyboard_Key_keySubLabel
 *
 */
public class CangjieKey extends Keyboard.Key {
	
	 	/** Label to display on top-left corner*/
		public CharSequence subLabel;
		
	        
        public CangjieKey(Resources res, Keyboard.Row parent, int x, int y, XmlResourceParser parser) {
            super(res, parent, x, y, parser);
            this.additionalDrawLogic = true;
            
            TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser), 
                    R.styleable.Cangjie_Keyboard_Key);
            
            
            subLabel = a.getText(R.styleable.Cangjie_Keyboard_Key_keySubLabel);
            
            a.recycle();
            
            //Log.i("CangjieKey",subLabel.toString());
            
        }
        
        
        
        /**
         * Overriding this method so that we can reduce the target area for the key that
         * closes the keyboard. 
         */
        @Override
        public boolean isInside(int x, int y) {
            return super.isInside(x, codes[0] == android.inputmethodservice.Keyboard.KEYCODE_CANCEL ? y - 10 : y);
        }
        
        
        
}


